#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :filter.py
# @Time      :2025/2/21 16:20
# @Author    :kk
from django.http import HttpResponseRedirect


def check_login(fn):
    def wrapper(request,*args,**kwargs):
        if request.session.get('user_id', False):
            return fn(request,*args,*kwargs)
        else:
            next = request.get_full_path()
            red = HttpResponseRedirect(f'/auth/login/?next={next}')
            return red
    return wrapper